\(\int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx\) [525]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 99 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {\left (4 a^2-b^2\right ) \text {arctanh}(\sin (c+d x))}{8 d}+\frac {5 a b \sec ^3(c+d x)}{12 d}+\frac {\left (4 a^2-b^2\right ) \sec (c+d x) \tan (c+d x)}{8 d}+\frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d} \]

[Out]

1/8*(4*a^2-b^2)*arctanh(sin(d*x+c))/d+5/12*a*b*sec(d*x+c)^3/d+1/8*(4*a^2-b^2)*sec(d*x+c)*tan(d*x+c)/d+1/4*b*se
c(d*x+c)^3*(a+b*tan(d*x+c))/d

Rubi [A] (verified)

Time = 0.13 (sec) , antiderivative size = 99, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.190, Rules used = {3589, 3567, 3853, 3855} \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {\left (4 a^2-b^2\right ) \text {arctanh}(\sin (c+d x))}{8 d}+\frac {\left (4 a^2-b^2\right ) \tan (c+d x) \sec (c+d x)}{8 d}+\frac {5 a b \sec ^3(c+d x)}{12 d}+\frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d} \]

[In]

Int[Sec[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]

[Out]

((4*a^2 - b^2)*ArcTanh[Sin[c + d*x]])/(8*d) + (5*a*b*Sec[c + d*x]^3)/(12*d) + ((4*a^2 - b^2)*Sec[c + d*x]*Tan[
c + d*x])/(8*d) + (b*Sec[c + d*x]^3*(a + b*Tan[c + d*x]))/(4*d)

Rule 3567

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*((d*Sec[
e + f*x])^m/(f*m)), x] + Dist[a, Int[(d*Sec[e + f*x])^m, x], x] /; FreeQ[{a, b, d, e, f, m}, x] && (IntegerQ[2
*m] || NeQ[a^2 + b^2, 0])

Rule 3589

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[b*(d*Sec
[e + f*x])^m*((a + b*Tan[e + f*x])/(f*(m + 1))), x] + Dist[1/(m + 1), Int[(d*Sec[e + f*x])^m*(a^2*(m + 1) - b^
2 + a*b*(m + 2)*Tan[e + f*x]), x], x] /; FreeQ[{a, b, d, e, f, m}, x] && NeQ[a^2 + b^2, 0] && NeQ[m, -1]

Rule 3853

Int[(csc[(c_.) + (d_.)*(x_)]*(b_.))^(n_), x_Symbol] :> Simp[(-b)*Cos[c + d*x]*((b*Csc[c + d*x])^(n - 1)/(d*(n
- 1))), x] + Dist[b^2*((n - 2)/(n - 1)), Int[(b*Csc[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n,
 1] && IntegerQ[2*n]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d}+\frac {1}{4} \int \sec ^3(c+d x) \left (4 a^2-b^2+5 a b \tan (c+d x)\right ) \, dx \\ & = \frac {5 a b \sec ^3(c+d x)}{12 d}+\frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d}+\frac {1}{4} \left (4 a^2-b^2\right ) \int \sec ^3(c+d x) \, dx \\ & = \frac {5 a b \sec ^3(c+d x)}{12 d}+\frac {\left (4 a^2-b^2\right ) \sec (c+d x) \tan (c+d x)}{8 d}+\frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d}+\frac {1}{8} \left (4 a^2-b^2\right ) \int \sec (c+d x) \, dx \\ & = \frac {\left (4 a^2-b^2\right ) \text {arctanh}(\sin (c+d x))}{8 d}+\frac {5 a b \sec ^3(c+d x)}{12 d}+\frac {\left (4 a^2-b^2\right ) \sec (c+d x) \tan (c+d x)}{8 d}+\frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.06 (sec) , antiderivative size = 120, normalized size of antiderivative = 1.21 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^2 \text {arctanh}(\sin (c+d x))}{2 d}-\frac {b^2 \text {arctanh}(\sin (c+d x))}{8 d}+\frac {2 a b \sec ^3(c+d x)}{3 d}+\frac {a^2 \sec (c+d x) \tan (c+d x)}{2 d}-\frac {b^2 \sec (c+d x) \tan (c+d x)}{8 d}+\frac {b^2 \sec ^3(c+d x) \tan (c+d x)}{4 d} \]

[In]

Integrate[Sec[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]

[Out]

(a^2*ArcTanh[Sin[c + d*x]])/(2*d) - (b^2*ArcTanh[Sin[c + d*x]])/(8*d) + (2*a*b*Sec[c + d*x]^3)/(3*d) + (a^2*Se
c[c + d*x]*Tan[c + d*x])/(2*d) - (b^2*Sec[c + d*x]*Tan[c + d*x])/(8*d) + (b^2*Sec[c + d*x]^3*Tan[c + d*x])/(4*
d)

Maple [A] (verified)

Time = 4.72 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.19

method result size
derivativedivides \(\frac {a^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+\frac {2 a b}{3 \cos \left (d x +c \right )^{3}}+b^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{4 \cos \left (d x +c \right )^{4}}+\frac {\sin ^{3}\left (d x +c \right )}{8 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{8}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{8}\right )}{d}\) \(118\)
default \(\frac {a^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+\frac {2 a b}{3 \cos \left (d x +c \right )^{3}}+b^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{4 \cos \left (d x +c \right )^{4}}+\frac {\sin ^{3}\left (d x +c \right )}{8 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{8}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{8}\right )}{d}\) \(118\)
risch \(-\frac {i {\mathrm e}^{i \left (d x +c \right )} \left (12 a^{2} {\mathrm e}^{6 i \left (d x +c \right )}-3 b^{2} {\mathrm e}^{6 i \left (d x +c \right )}+12 a^{2} {\mathrm e}^{4 i \left (d x +c \right )}+21 b^{2} {\mathrm e}^{4 i \left (d x +c \right )}+64 i a b \,{\mathrm e}^{4 i \left (d x +c \right )}-12 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-21 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+64 i a b \,{\mathrm e}^{2 i \left (d x +c \right )}-12 a^{2}+3 b^{2}\right )}{12 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{2 d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2}}{8 d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{2 d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2}}{8 d}\) \(255\)

[In]

int(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(a^2*(1/2*sec(d*x+c)*tan(d*x+c)+1/2*ln(sec(d*x+c)+tan(d*x+c)))+2/3*a*b/cos(d*x+c)^3+b^2*(1/4*sin(d*x+c)^3/
cos(d*x+c)^4+1/8*sin(d*x+c)^3/cos(d*x+c)^2+1/8*sin(d*x+c)-1/8*ln(sec(d*x+c)+tan(d*x+c))))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 120, normalized size of antiderivative = 1.21 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {3 \, {\left (4 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{4} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (4 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{4} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 32 \, a b \cos \left (d x + c\right ) + 6 \, {\left ({\left (4 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, b^{2}\right )} \sin \left (d x + c\right )}{48 \, d \cos \left (d x + c\right )^{4}} \]

[In]

integrate(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/48*(3*(4*a^2 - b^2)*cos(d*x + c)^4*log(sin(d*x + c) + 1) - 3*(4*a^2 - b^2)*cos(d*x + c)^4*log(-sin(d*x + c)
+ 1) + 32*a*b*cos(d*x + c) + 6*((4*a^2 - b^2)*cos(d*x + c)^2 + 2*b^2)*sin(d*x + c))/(d*cos(d*x + c)^4)

Sympy [F]

\[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \sec ^{3}{\left (c + d x \right )}\, dx \]

[In]

integrate(sec(d*x+c)**3*(a+b*tan(d*x+c))**2,x)

[Out]

Integral((a + b*tan(c + d*x))**2*sec(c + d*x)**3, x)

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 129, normalized size of antiderivative = 1.30 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {3 \, b^{2} {\left (\frac {2 \, {\left (\sin \left (d x + c\right )^{3} + \sin \left (d x + c\right )\right )}}{\sin \left (d x + c\right )^{4} - 2 \, \sin \left (d x + c\right )^{2} + 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - 12 \, a^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + \frac {32 \, a b}{\cos \left (d x + c\right )^{3}}}{48 \, d} \]

[In]

integrate(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/48*(3*b^2*(2*(sin(d*x + c)^3 + sin(d*x + c))/(sin(d*x + c)^4 - 2*sin(d*x + c)^2 + 1) - log(sin(d*x + c) + 1)
 + log(sin(d*x + c) - 1)) - 12*a^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) - log(sin(d*x + c) + 1) + log(sin(d*x
+ c) - 1)) + 32*a*b/cos(d*x + c)^3)/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 249 vs. \(2 (91) = 182\).

Time = 0.51 (sec) , antiderivative size = 249, normalized size of antiderivative = 2.52 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {3 \, {\left (4 \, a^{2} - b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 3 \, {\left (4 \, a^{2} - b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + \frac {2 \, {\left (12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{7} + 3 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{7} - 48 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{6} - 12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 21 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 48 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - 12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 21 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 16 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 16 \, a b\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{4}}}{24 \, d} \]

[In]

integrate(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/24*(3*(4*a^2 - b^2)*log(abs(tan(1/2*d*x + 1/2*c) + 1)) - 3*(4*a^2 - b^2)*log(abs(tan(1/2*d*x + 1/2*c) - 1))
+ 2*(12*a^2*tan(1/2*d*x + 1/2*c)^7 + 3*b^2*tan(1/2*d*x + 1/2*c)^7 - 48*a*b*tan(1/2*d*x + 1/2*c)^6 - 12*a^2*tan
(1/2*d*x + 1/2*c)^5 + 21*b^2*tan(1/2*d*x + 1/2*c)^5 + 48*a*b*tan(1/2*d*x + 1/2*c)^4 - 12*a^2*tan(1/2*d*x + 1/2
*c)^3 + 21*b^2*tan(1/2*d*x + 1/2*c)^3 - 16*a*b*tan(1/2*d*x + 1/2*c)^2 + 12*a^2*tan(1/2*d*x + 1/2*c) + 3*b^2*ta
n(1/2*d*x + 1/2*c) + 16*a*b)/(tan(1/2*d*x + 1/2*c)^2 - 1)^4)/d

Mupad [B] (verification not implemented)

Time = 7.25 (sec) , antiderivative size = 216, normalized size of antiderivative = 2.18 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {\left (a^2+\frac {b^2}{4}\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^7-4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+\left (\frac {7\,b^2}{4}-a^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5+4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+\left (\frac {7\,b^2}{4}-a^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-\frac {4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{3}+\left (a^2+\frac {b^2}{4}\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+\frac {4\,a\,b}{3}}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^8-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+6\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}+\frac {\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )\,\left (a^2-\frac {b^2}{4}\right )}{d} \]

[In]

int((a + b*tan(c + d*x))^2/cos(c + d*x)^3,x)

[Out]

((4*a*b)/3 + tan(c/2 + (d*x)/2)*(a^2 + b^2/4) + tan(c/2 + (d*x)/2)^7*(a^2 + b^2/4) - tan(c/2 + (d*x)/2)^3*(a^2
 - (7*b^2)/4) - tan(c/2 + (d*x)/2)^5*(a^2 - (7*b^2)/4) - (4*a*b*tan(c/2 + (d*x)/2)^2)/3 + 4*a*b*tan(c/2 + (d*x
)/2)^4 - 4*a*b*tan(c/2 + (d*x)/2)^6)/(d*(6*tan(c/2 + (d*x)/2)^4 - 4*tan(c/2 + (d*x)/2)^2 - 4*tan(c/2 + (d*x)/2
)^6 + tan(c/2 + (d*x)/2)^8 + 1)) + (atanh(tan(c/2 + (d*x)/2))*(a^2 - b^2/4))/d